package com.sims.action;

import com.opensymphony.xwork2.ActionSupport;

public class StudentAdd extends ActionSupport{
	private String id;
	private String name;
	private String sex;
	private String height;
	private String study;
	private String clas;
	private String qq;
	private String number;
	private String zhuanye;
	
	

	@Override
	public String execute() throws Exception {
		return SUCCESS;
	}
	
	public String getZhuanye() {
		return zhuanye;
	}

	public String getId() {
		return id;
	}

	public String getName() {
		return name;
	}

	public String getSex() {
		return sex;
	}

	public String getHeight() {
		return height;
	}

	public String getStudy() {
		return study;
	}

	public String getClas() {
		return clas;
	}

	public String getQq() {
		return qq;
	}

	public String getNumber() {
		return number;
	}
	
	public void setZhuanye(String zhuanye) {
		this.zhuanye = zhuanye;
	}

	public void setId(String id) {
		this.id = id;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setSex(String sex) {
		this.sex = sex;
	}

	public void setHeight(String height) {
		this.height = height;
	}

	public void setStudy(String study) {
		this.study = study;
	}

	public void setClas(String clas) {
		this.clas = clas;
	}

	public void setQq(String qq) {
		this.qq = qq;
	}

	public void setNumber(String number) {
		this.number = number;
	}

	@Override
	public void validate() {
		if(id != null&&name !=null&&height !=null&&clas !=null&&qq !=null&&number !=null){
			id = id.trim();
			name = name.trim();
			height = height.trim();
			clas = clas.trim();
			qq = qq.trim();
			number = number.trim();
		}
		if(!id.matches("\\d+")){
			this.addFieldError("id", "请输入数字！");
		}
		if(name==null || name.length()<=2){
			this.addFieldError("name", "请填写正确的姓名！大于2个字符");
		}
		if(!height.matches("\\d+")){
			this.addFieldError("height", "身高必须是数字");
		}
		if(!qq.matches("\\d+")){
			this.addFieldError("qq", "请QQ填写整数");
		}
		if(!number.matches("\\d+") || number.length()!=11){
			this.addFieldError("number", "请填写有效的11位电话号码");
		}
	}

}